package Q5;

import java.util.*;
/*
一盒扑克牌的相关方法
 */
public class pack {
    static List<pokerCard> cards = new ArrayList<>();
    TreeSet<pokerCard> user1 = new TreeSet<>();
    TreeSet<pokerCard> user2 = new TreeSet<>();
    TreeSet<pokerCard> user3 = new TreeSet<>();
//    1 初始一副扑克牌并将这54张扑克牌打乱顺序
    public pack() {
        creatCards();
        Collections.shuffle(cards);
    }
    public void createCard(String call,int i){
        pokerCard cardHearts = new pokerCard("红桃",call,i);
        cards.add(cardHearts);
        pokerCard cardClubs = new pokerCard("梅花",call,i);
        cards.add(cardClubs);
        pokerCard cardDiamonds = new pokerCard("方块",call,i);
        cards.add(cardDiamonds);
        pokerCard cardSpades = new pokerCard("黑桃",call,i);
        cards.add(cardSpades);
    }
    public void creatCards(){
        for(int i=0; i< 13; i++){
                if(0 == i){ createCard("3", i);}
                else if (1 == i){ createCard("4", i); }
                else if (2 == i){ createCard("5", i); }
                else if (3 == i){ createCard("6", i);}
                else if (4 == i){createCard("7", i);}
                else if (5 == i){createCard("8",i);}
                else if (6 == i){createCard("9",i);}
                else if (7 == i){createCard("10", i);}
                else if (8 == i){createCard("J",i);}
                else if (9 == i){createCard("Q",i);}
                else if (10 == i){createCard("K",i);}
                else if (11 == i){createCard("A", i);}
                else if (12 == i){createCard("2", i);}
            }
        cards.add(new pokerCard(" ","大王",14));
        cards.add(new pokerCard(" ","小王",13));
    }
//  2 自定义三个玩家摸牌实现方法
    public void BeginOne(TreeSet user){
        pokerCard card = cards.get(0);
//        System.out.println(card);
        user.add(card);
        cards.remove(card);
    }
    public void startGame(){
        for(int i = 0; i < 17; i++){
            BeginOne(user1);
//            System.out.println(user1);
            BeginOne(user2);
//            System.out.println(user2);
            BeginOne(user3);
//            System.out.println(user3);
//            System.out.println(cards.size());
        }
    }
// 3 生成每个玩家牌面的获取和留作底牌的获取
    public static List<pokerCard> getCards() {
        return cards;
    }

    public TreeSet<pokerCard> getUser1() {
        return user1;
    }

    public TreeSet<pokerCard> getUser2() {
        return user2;
    }

    public TreeSet<pokerCard> getUser3() {
        return user3;
    }

}
